<template>
  <div style="position: relative">
    <!-- 操作按钮区域 -->
    <!-- <div class="table-operator" v-if="stage !== '05010' && stage !== '05050'">
      <a-button :disabled="status == '9' || status == '2'" v-permission="['10050']" type="primary" @click="showConfirm">
        提交审核
      </a-button>
      <a-button :disabled="status !== '2'" v-permission="['10060']" @click="setApproveReason('9')"> 同意 </a-button>
      <a-button :disabled="status !== '2'" v-permission="['10060']" type="danger" @click="setApproveReason('1')">
        拒绝
      </a-button>
      <a-button @click="showShjl" style="margin-top:10px">审核记录</a-button>
    </div> -->
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="table_header_blue"
        :row-class-name="tableRowClassName"
        @change="handleTableChange"
      >
        <span slot="tempName" slot-scope="text, record">
          <a style="text-decoration: underline" @click="handleDownloadFile(record.tempUrl)">{{ record.tempName }}</a>
        </span>
        <span slot="jdxwsName" slot-scope="text, record">
          <a style="text-decoration: underline" @click="handleDownloadFile(record.jdxwsUrl)">{{ record.jdxwsName }}</a>
        </span>
        <span slot="actionName">
          <a-button
            v-if="stage !== '05010' && stage !== '05050'"
            v-permission="['10050']"
            size="small"
            @click="handleAdd('添加审计参考资料')"
            type="primary"
            icon="plus"
            >新增</a-button
          >
          <span v-else>操作</span>
        </span>

        <span slot="action" slot-scope="text, record" v-if="stage !== '05010' && stage !== '05050'">
          <a @click="handleEdit(record, '编辑审计参考资料')">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>
        <span slot="action" slot-scope="text, record" v-else>
          <a-button type="link" @click="handleCheck(record, '查看')">查看</a-button>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->
    <ModelForm ref="modalForm" :id="id" :stage="stage" @ok="modalFormOk"></ModelForm>
    <SelectApprove ref="approver" :id="id" @submitData="handleSubmit"></SelectApprove>
    <SetReason ref="setReason" @approveReason="approveData"></SetReason>
    <shjlModal ref="shjlModal" :id="id" :typeId="typeId" :apiUrl="url.applyLog"></shjlModal>
  </div>
</template>
<script>
// 表头
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { butStatus } from '../public/butStatus'
import ModelForm from './ModelForm'
import columns from './indexColumns'
import SelectApprove from '../public/SelectApprover'
import SetReason from '../public/SetReason'
import shjlModal from '../shjlModal'
import { httpAction } from '@/api/manage'

export default {
  props: ['id', 'stage', 'type'],
  name: 'bcxsjws',
  mixins: [JeecgListMixin, butStatus],
  components: {
    ModelForm,
    SetReason,
    SelectApprove,
    shjlModal,
  },
  data() {
    return {
      queryParam: {
        proId: this.id,
        stage: this.stage,
        typeId: this.type,
      },
      // 表头
      typeId: this.type,
      columns: columns(this),
      url: {
        list: '/sjxmzygl/sjWorkBcxsjws/queryJdxwsList',
        delete: '/sjxmzygl/sjWorkBcxsjws/remove',
        submit: '/sjxmzygl/sjWorkUsers/submitAudit',
        approve: '/sjxmzygl/sjWorkUsers/zyApplyCommit',
        applyLog: '/sjxmzygl/sjWorkApplyLog/queryApplyLog',
      },
    }
  },
  methods: {
    handleOK(record) {
      httpAction('/sjxmzygl/sjWorkBcxsjws/bcxsjwsjdQr', { id: record.id }, 'put').then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.loadData()
        } else {
          this.$message.error(res.message)
        }
      })
    },
    // // 新增成功
    // newData(val) {
    //   console.log(1333,val)
    //   let obj = Object.assign({jdxwsId: null, jdxwsName: null}, val)
    //   this.addList(obj)
    // },
    // // 新增或调增计划项目
    // addList(val) {
    //   console.log(111,val)
    //   this.dataSource.push(val)
    // },
    tableRowClassName(record, index) {
      record.index = index
    },
    modalFormOk() {
      this.loadData()
    },
    handleDownloadFile(fileUrl) {
      this.$message.success('正在下载，请稍等！')
      let url = `${window._CONFIG['domianURL']}/sys/common/download${fileUrl}`
      window.open(url, '_blank')
    },
  },
}
</script>

<style lang="less" scoped>
@import '~@assets/less/tableTheme.less';
@import '~@assets/less/common.less';
.ant-row {
  height: 100%;

  .ant-col {
    height: 100%;

    .ant-card {
      height: 100%;

      /deep/ .ant-card-body {
        padding: 15px;
      }
    }
  }
}
</style>